#include <cstdio>
#include <string.h>
#include <math.h>
#include <iostream>
#define MAX 50010
using namespace std;
int c[MAX];

int lowbit(int x)
{
	return x&(-x);
}
int insert(int k,int value)
{
	while(k<=50001){
		c[k]+=value;
		k+=lowbit(k);
	}
}

long long getsum(int k)
{
	long long sum=0;
	while(k>0){
		sum+=c[k];
		k-=lowbit(k);
	}
	//cout<<sum<<endl;
	return sum;
}

int main()
{
	int T,i,j,k,t;
	scanf("%d",&T);
	t=0;
	while(T--){
		int n;
		memset(c,0,sizeof(c));
		scanf("%d",&n);
		for( i=1;i<=n;i++){
			scanf("%d",&k);
			insert(i,k);
		}
		char order[20];
		scanf("%s",order);
		printf("Case %d:\n",++t);
		while(strcmp(order,"End")!=0){
			int x,y;
			scanf("%d%d",&x,&y);
			if(strcmp(order,"Query")==0){
				printf("%lld\n",getsum(y)-getsum(x-1));
			}
			else if (strcmp(order,"Add")==0 ){
				insert(x,y);
			}
			else if(strcmp(order,"Sub")==0){
				insert(x,(-1)*y);
			}
			scanf("%s",order);
		}
	}
}

